/*******************************************************************************
*   				               DOFILE: GAME GRAPHS					                       *
********************************************************************************

    **  OUTLINE:

        - All game graphs

********************************************************************************/

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  * Load dataset

  use "$Endline_dtFin/data_angolacbm.dta", clear

bysort treatment: sum Gp_dg_faces0_2

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

preserve

collapse (mean) meanpunish= Gp_dg_faces0_2 (sd) sdpunish=Gp_dg_faces0_2 (count) n=Gp_dg_faces0_2, by(treatment)

generate hipunish = meanpunish + invttail(n-1,0.025)*(sdpunish / sqrt(n))
generate lopunish = meanpunish - invttail(n-1,0.025)*(sdpunish / sqrt(n))

graph twoway  (bar meanpunish treatment if treatment==0, color(gs0) lcolor(gs0)) ///
              (bar meanpunish treatment if treatment==1, color(gs4) lcolor(gs0)) ///
              (bar meanpunish treatment if treatment==2, color(gs8) lcolor(gs0)) ///
              (bar meanpunish treatment if treatment==3, color(gs12) lcolor(gs0)) ///
              (rcap hipunish lopunish treatment, lw(thin) lc(gs5)), ///
              yscale(r(0(50)200)) ///
              ylabel(0(50)200) ///
              yline(0(50)200, lcolor(gs12)) ///
              subtitle("Average contribution to punishment fund demanded by parent representative") ///
              graphregion(color(white)) ///
              legend( order(1 "C: Control" 2 "T1: Information" 3 "T2: Meetings" 4 "T3: Combined") ) ///
              xlabel(none) ///
              xscale(r(-1(1)4)) ///
              xtitle("") ///
              note( "Note:  Capped lines indicate the 95 percent confidence intervals.")  ///
              saving("$Endline_outRaw/Figure5.gph", replace)


graph export "$Endline_outFin/Figure5.png", replace as(png) name("Graph")


restore


  *Graph DG Teacher (Figure A5)
  histogram Gt_dg if version==1, bin(5) percent by(treatment, note("")) ///
  scheme(s1mono) ///
  yline(0(10)40, lcolor(gs14)) ///
  xlabel(200 "0" 600 "500" 1000 "1000" 1400 "1500" 1800 "2000", tlength(0)) ///
  plotregion(color(white) icolor(white)) ///
  xtitle("Amount given to parents") ///
  ytitle("Percentage") ///
  saving("$Endline_outRaw/FigureA5.gph", replace)

  graph export "$Endline_outFin/FigureA5.png", replace as(png) name("Graph")
